package com.hh.vietnameseproject.ui.me.record

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.hh.vietnameseproject.R
import com.hh.vietnameseproject.logic.model.RecordList
import java.util.ArrayList

class RecordAdapter(val context:Context,val list:ArrayList<RecordList>): RecyclerView.Adapter<RecordAdapter.ViewHolder>() {
    class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        val recordTime = itemView.findViewById<TextView>(R.id.recordTime)
        val recordContinueDay = itemView.findViewById<TextView>(R.id.recordContinueDay)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.record_item,parent,false)
        return ViewHolder(view)
    }

    override fun getItemCount()= list.size

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        holder.recordTime.text = list[position].date
        holder.recordContinueDay.text = list[position].continuousdays
    }

}